home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
3006
/
3006.xpi
/
chrome
/
dwhelper.jar
/
content
/
smart-name.xml
< prev
next >
Wrap
Extensible Markup Language
|
2010-01-15
|
15KB
|
542 lines
<?xml version="1.0"?>
<!-- *****************************************************************************
* Copyright (c) 2006-2009 Michel Gutierrez. All Rights Reserved.
****************************************************************************** -->
<!DOCTYPE bindings SYSTEM "chrome://dwhelper/locale/dwhelper.dtd" >
<bindings xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:xbl="http://www.mozilla.org/xbl">
<binding id="SmartNameLocation" extends="widgets.xml#widget">
<xbl:content xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<vbox flex="1">
<label value="&smartname.define.value-for-page;"/>
<textbox anonid="xSample" readonly="true" style="-moz-appearance: none; background-color: #FFFFC0; padding: 5px; color: Black; border: 1px solid #808000; width: 400px; overlap: hidden;" flex="1" value="testXX"/>
<groupbox>
<caption>
<checkbox label="Advanced" anonid="xAdvanced" oncommand="this.parentNode.parentNode.parentNode.parentNode.updateAdvanced()"/>
</caption>
<vbox flex="1" collapsed="true" anonid="xAdvPanel">
<grid flex="1">
<columns>
<column/>
<column flex="1"/>
</columns>
<rows>
<row align="center">
<label value="&smartname.define.domain;"/>
<vbox>
<label anonid="xSimpleDomain" hidden="true"/>
<radiogroup anonid="xMultiDomains" hidden="true" oncommand="this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.updateDomain()"/>
</vbox>
</row>
<row align="center">
<label value="&smartname.define.xpath;"/>
<textbox anonid="xXPath" oninput="this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.updateFromSelection()"/>
</row>
<row align="center">
<label value="&smartname.define.regexp;"/>
<textbox anonid="xRegExp" oninput="this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.updateFromSelection()"/>
</row>
</rows>
</grid>
<groupbox collapsed="true" anonid="xPrev">
<caption><text value="&smartname.define.previous-value;"/></caption>
<grid flex="1" >
<columns>
<column/>
<column flex="1"/>
</columns>
<rows>
<row align="center">
<label value="&smartname.define.xpath;"/>
<textbox anonid="xPrevXPath" style="-moz-appearance: none; background-color: #C0C0C0;" readonly="true"/>
</row>
<row align="center">
<label value="&smartname.define.regexp;"/>
<textbox anonid="xPrevRegExp" style="-moz-appearance: none; background-color: #C0C0C0;" readonly="true"/>
</row>
</rows>
</grid>
</groupbox>
</vbox>
</groupbox>
</vbox>
<children style="display: none;"/>
</xbl:content>
<implementation>
<constructor>
<![CDATA[
this.smartNamer = Components.classes["@downloadhelper.net/smart-namer;1"]
.getService(Components.interfaces.dhISmartNamer);
this.simpleDomain=true;
this.NS="http://downloadhelper.net/1.0#";
]]>
</constructor>
<method name="setNode">
<parameter name="node"/>
<body>
<![CDATA[
this.document=node.ownerDocument;
var domain=/\/\/([^\/]+)\//.exec(node.ownerDocument.URL)[1];
if(/^([^\.]*\.)?[^\.]*$/.test(domain)) { // simple domain
this.xSimpleDomain.value=domain;
this.xSimpleDomain.setAttribute("hidden","false");
this.domain=domain;
} else {
var defDomain=null;
var parts=domain.split(".");
for(var i=0;i<parts.length-1;i++) {
var radio=document.createElement("radio");
var subdomain=parts.slice(i,parts.length).join(".");
radio.setAttribute("label",subdomain);
radio.setAttribute("value",subdomain);
radio.setAttribute("id",subdomain);
if(i==0)
radio.setAttribute("selected","true");
this.xMultiDomains.appendChild(radio);
if(defDomain==null)
defDomain=subdomain;
}
this.xMultiDomains.setAttribute("hidden","false");
this.simpleDomain=false;
this.domain=defDomain;
}
var xpath=this.util.generateXPath(node);
this.xXPath.value=xpath;
this.xRegExp.value=".*";
this.updatePrevious(this.domain,this.mode);
this.updateFromSelection(node.ownerDocument);
]]>
</body>
</method>
<method name="setMode">
<parameter name="mode"/>
<body>
<![CDATA[
this.mode=mode;
]]>
</body>
</method>
<method name="updatePrevious">
<parameter name="domain"/>
<parameter name="mode"/>
<body>
<![CDATA[
var rdfNode=this.smartNamer.getEntry(domain,mode);
if(rdfNode) {
var ds=this.smartNamer.getDatasource();
this.xPrevXPath.value=Util.getPropertyValueRS(ds,rdfNode,this.NS+"xpath");
this.xPrevRegExp.value=Util.getPropertyValueRS(ds,rdfNode,this.NS+"regexp");
this.xPrev.collapsed=false;
} else
this.xPrev.collapsed=true;
]]>
</body>
</method>
<method name="updateAdvanced">
<body>
<![CDATA[
this.xAdvPanel.setAttribute("collapsed",!this.xAdvanced.checked);
window.sizeToContent();
]]>
</body>
</method>
<method name="updateFromSelection">
<body>
<![CDATA[
var text;
try {
text=this.util.xpGetString(this.document.documentElement,this.xXPath.value);
this.xXPath.style.color="Black";
} catch(e) {
this.xSample.value="";
this.xXPath.style.color="Red";
return;
}
text=text.replace(/\s{1,}/g,' ');
text=text.replace(/^\s+/,'');
text=text.replace(/\s+$/,'');
if(this.xRegExp.value.length>0) {
var m=null;
try {
m=new RegExp(this.xRegExp.value).exec(text);
this.xRegExp.style.color="Black";
} catch(e) {
this.xRegExp.style.color="Red";
}
if(m==null || m.length==0)
text="";
else if(m.length==1)
text=m[0];
else if(m.length>1)
text=m[1];
text=text.replace(/^\s+/,'');
text=text.replace(/\s+$/,'');
}
this.xSample.value=text;
]]>
</body>
</method>
<method name="updateDomain">
<body>
<![CDATA[
this.domain=this.xMultiDomains.selectedItem.getAttribute("value");
this.updatePrevious(this.domain,this.mode);
window.sizeToContent();
]]>
</body>
</method>
<property name="value">
<setter>
<![CDATA[
]]>
</setter>
<getter>
<![CDATA[
var value=Components.classes["@mozilla.org/properties;1"].
createInstance(Components.interfaces.nsIProperties);
this.util.setPropsString(value,"mode",this.mode);
this.util.setPropsString(value,"xpath",this.xXPath.value);
this.util.setPropsString(value,"regexp",this.xRegExp.value);
if(this.simpleDomain)
this.util.setPropsString(value,"domain",this.xSimpleDomain.value);
else
this.util.setPropsString(value,"domain",this.xMultiDomains.selectedItem.getAttribute("value"));
return value;
]]>
</getter>
</property>
</implementation>
</binding>
<binding id="SmartNameListControl" extends="widgets.xml#widget">
<xbl:content xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<vbox
flex="1"
anonid="xPanel">
<hbox align="center">
<label value="&smartname.list.label.type;"/>
<menulist anonid="xType" oncommand="this.parentNode.parentNode.parentNode.typeChanged()">
<menupopup>
<menuitem label="&smartname.list.type.name;" value="name"/>
<menuitem label="&smartname.list.type.descr;" value="descr"/>
</menupopup>
</menulist>
</hbox>
<tree
anonid="xTree"
flex="1"
enableColumnDrag="false"
hidecolumnpicker="true"
flags="dont-build-content"
datasources="rdf:null"
ref="urn:root"
onselect="this.parentNode.parentNode.updateSelection()"
sortResource="http://downloadhelper.net/1.0#domain"
sortDirection="ascending"
style="min-height:40px;"
>
<treecols>
<treecol
id="dwhelper-smartname-domain-col0"
anonid="xCol0"
primary="true"
flex="1"
label="&smartname.column.domain;"
sort="?domain"
/>
</treecols>
<template>
<rule>
<conditions>
<content uri="?root"/>
<member container="?root" child="?entry"/>
<triple
anonid="xModeTriple"
subject="?entry"
predicate="http://downloadhelper.net/1.0#mode"
object="name"/>
<triple
subject="?entry"
predicate="http://downloadhelper.net/1.0#domain"
object="?domain"/>
</conditions>
<action>
<treechildren>
<treeitem
uri="?entry" open="true">
<treerow>
<treecell
label="?domain"
/>
</treerow>
</treeitem>
</treechildren>
</action>
</rule>
</template>
</tree>
<hbox>
<button label="&smartname.list.button.delete;" anonid="xDelBut" oncommand="this.parentNode.parentNode.parentNode.remove();" collapsed="true"/>
<button label="&smartname.list.button.edit;" anonid="xEditBut" oncommand="this.parentNode.parentNode.parentNode.edit();" collapsed="true"/>
<spacer flex="1"/>
<button label="&smartname.list.button.import;" oncommand="this.parentNode.parentNode.parentNode.import();"/>
</hbox>
</vbox>
<children style="display: none;"/>
</xbl:content>
<implementation>
<constructor>
<![CDATA[
this.core=Components.classes["@downloadhelper.net/core;1"].
getService(Components.interfaces.dhICore);
this.smartNamer = Components.classes["@downloadhelper.net/smart-namer;1"]
.getService(Components.interfaces.dhISmartNamer);
this.util.setDatasource(this.xTree,this.smartNamer.getDatasource());
]]>
</constructor>
<destructor>
<![CDATA[
]]>
</destructor>
<method name="remove">
<body>
<![CDATA[
var selectCount = this.xTree.view.selection.count;
if(selectCount>0) {
var res=this.xTree.builderView.getResourceAtIndex(this.xTree.currentIndex);
if(res!=null) {
this.smartNamer.removeEntry(res);
this.core.updateSmartName();
}
}
]]>
</body>
</method>
<method name="edit">
<body>
<![CDATA[
]]>
</body>
</method>
<method name="import">
<body>
<![CDATA[
this.smartNamer.import();
]]>
</body>
</method>
<method name="typeChanged">
<body>
<![CDATA[
this.xModeTriple.setAttribute("object",this.xType.value);
this.xTree.builder.rebuild();
]]>
</body>
</method>
<method name="updateSelection">
<body>
<![CDATA[
if(this.xTree.currentIndex<0) {
this.xDelBut.collapsed=true;
//this.xEditBut.collapsed=true;
} else {
this.xDelBut.collapsed=false;
//this.xEditBut.collapsed=false;
}
]]>
</body>
</method>
</implementation>
<handlers>
<!--
<handler event="DOMAttrModified">
<![CDATA[
]]>
</handler>
-->
</handlers>
</binding>
<binding id="SmartNameOverlap" extends="widgets.xml#widget">
<xbl:content xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<vbox
flex="1"
anonid="xPanel">
<description>&smartname.overlap.description;</description>
<tree
anonid="xTree"
flex="1"
enableColumnDrag="true"
hidecolumnpicker="true"
editable="true"
style="height: 150px; width: 300px;"
>
<treecols>
<treecol
id="dwhelper-smartname-domain-col2"
primary="false"
flex="0"
type="checkbox"
editable="true"
/>
<splitter class="tree-splitter"/>
<treecol
id="dwhelper-smartname-domain-col0"
primary="true"
flex="1"
label="&smartname.column.domain;"
/>
<splitter class="tree-splitter"/>
<treecol
id="dwhelper-smartname-domain-col1"
primary="false"
flex="0"
label="&smartname.column.mode;"
/>
</treecols>
<treechildren anonid="xRows" flex="1"/>
</tree>
<hbox align="center">
<!--
<button label="&smartname.overlap.button.selectall;" oncommand="this.parentNode.parentNode.parentNode.select(true);"/>
<button label="&smartname.overlap.button.selectnone;" oncommand="this.parentNode.parentNode.parentNode.select(false);"/>
-->
<description value="&smartname.overlap.select;"/>
<html:a onclick="this.parentNode.parentNode.parentNode.select(true);">&smartname.overlap.selectall;</html:a>
<spacer style="width: 8px;"/>
<html:a onclick="this.parentNode.parentNode.parentNode.select(false);">&smartname.overlap.selectnone;</html:a>
</hbox>
</vbox>
<children style="display: none;"/>
</xbl:content>
<implementation>
<constructor>
<![CDATA[
this.smartNamer = Components.classes["@downloadhelper.net/smart-namer;1"]
.getService(Components.interfaces.dhISmartNamer);
this.datasource=this.smartNamer.getDatasource();
this.NS="http://downloadhelper.net/1.0#";
]]>
</constructor>
<destructor>
<![CDATA[
]]>
</destructor>
<method name="select">
<parameter name="all"/>
<body>
<![CDATA[
for(var ti=this.xRows.firstChild;ti;ti=ti.nextSibling) {
var tc=ti.firstChild.firstChild;
tc.setAttribute("value",""+all);
}
]]>
</body>
</method>
<property name="value">
<setter>
<![CDATA[
while(this.xRows.firstChild) {
this.xRows.removeChild(this.xRows.firstChild);
}
for(var i in val) {
var res=val[i].QueryInterface(Components.interfaces.nsIRDFResource);
var domain=this.util.getPropertyValueRS(this.datasource,res,this.NS+"domain");
var mode=this.util.getPropertyValueRS(this.datasource,res,this.NS+"mode");
var ti=document.createElement("treeitem");
this.xRows.appendChild(ti);
var tr=document.createElement("treerow");
ti.appendChild(tr);
var tc=document.createElement("treecell");
tc.setAttribute("value","false");
tc.setAttribute("entry-resource",res.Value);
tr.appendChild(tc);
tc=document.createElement("treecell");
tc.setAttribute("editable",false);
tc.setAttribute("label",domain);
tr.appendChild(tc);
tc=document.createElement("treecell");
tc.setAttribute("editable",false);
tc.setAttribute("label",this.util.getText("smartname.overlap."+mode));
tr.appendChild(tc);
}
]]>
</setter>
<getter>
<![CDATA[
var RDF=this.util.getRDF();
var selected=[];
for(var ti=this.xRows.firstChild;ti;ti=ti.nextSibling) {
var tc=ti.firstChild.firstChild;
if(tc.getAttribute("value")=="false") {
selected.push(RDF.GetResource(tc.getAttribute("entry-resource")));
}
}
return selected;
]]>
</getter>
</property>
</implementation>
</binding>
</bindings>